package com.cqc.other.classConstruct;

import java.util.function.Supplier;

/**
 * @author cui
 * @date 2023/8/17 20:06
 * @description
 **/
public class Parent {

    private String username = "parent";
    private Supplier<String> passwordSupplier;

    public Parent() {
        System.out.println("Parent无参构造方法，" + this.getClass().getName());
        this.f1();
    }

    public Parent(String username) {
        this.username = username;
        System.out.println("Parent有参构造方法，" + this.getClass().getName() + ",username=" + username);
        passwordSupplier = () -> {
            this.f2();
            return null;
        };
    }

    public String getUsername() {
        return username;
    }

    public void setUsername(String username) {
        this.username = username;
    }


    protected void f1() {
        System.out.println("Parent.f1()");
    }

    protected void f2() {
        System.out.println("Parent.f2()");
    }

    public void go() {
        System.out.println("Parent.go()");
        String s = passwordSupplier.get();
        System.out.println("Parent.go() s=" + s);
    }
}
